const nodemailer=require("nodemailer")

const semdMail=async (email,title,pwd)=>{
    // 配置发送邮件的通道
    let mailtransporter = nodemailer.createTransport({
        service: "qq",
        port: 465,
        secureConnection: true, // true for 465, false for other ports
        auth: {
          user: "2691750681@qq.com", // generated ethereal user
          pass: "pwtxcxvajzvmdffh", // generated ethereal password
        },
    });

    // 设置发送邮件的参数
    let mailOptions={
        from:"2691750681@qq.com",
        to:email,
        subject:title,
        text:`你猜这是什么${pwd}`,
        html:`<h1>你的密码是${pwd}</h1>`
    }

    return new Promise((resolve, reject) => {
        mailtransporter.sendMail(mailOptions,(err,info)=>{
            if(err){
                reject(new Error(err))
            }else{
                resolve({
                    code:200,
                    info
                })
            }
        })
    })
}

module.exports={
    semdMail
}